﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Game_Engine
{
    public class GUIElement : IUpdateable
    {
        public Rectangle Bounds { get; set; }
        public Texture2D Texture { get; set; }
        public Color BackgroundColor { get; set; }
        public String Text { get; set; }
        public Color TextColor { get; set; }
        public bool Selected { get; set; }

        public delegate void EventHandler(GUIElement sender);
        public event EventHandler Action;
        protected void OnAction()
        {
            if (Action != null)
                Action(this);
        }

        public GUIElement()
        { }

        public GUIElement(Texture2D texture, Rectangle rectangle, String text, Color background, Color textColor)
        {
            Texture = texture;
            BackgroundColor = background;
            Bounds = rectangle;
            Text = text;
            TextColor = textColor;
            Selected = false;
        }

        public virtual void Update()
        {

        }

        public virtual void Draw(SpriteBatch spriteBatch, SpriteFont font)
        {
            if (Texture != null)
                spriteBatch.Draw(Texture, Bounds, Selected ? BackgroundColor : Color.White);
        }
    }
}
